package com.lin.spring.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName DynamicProxy
 * @Description dynamicProxy
 * @Author lin
 * @Date 2021/11/11 下午10:09
 * @Version V1.0
 */
public class DynamicProxy implements InvocationHandler {
    private Object object;

    public DynamicProxy(Object object){
        this.object = object;
    }

    // 动态生成代理对象
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("动态打出租广告");
        Object invoke = method.invoke(object, args);
        System.out.println("动态收中介费");
        return invoke;
    }
}
